#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;
const int N = 1010, M = 5010;
const double eps = 0.00001;

int n, m;
int h[N], e[M], ne[M], f[M], t[M], idx; 
double dist[M];
int cnt[N], q[N];
bool st[N];

void add(int a, int b, int c){
    e[idx] = b;
    ne[idx] = h[a];
    t[idx] = c;
    h[a] = idx ++;
}

bool check(double mid)
{
    memset(dist, 0, sizeof dist);
    memset(st, 0, sizeof st);
    memset(cnt, 0, sizeof cnt);
    int hh = 0, tt = 0;
    for(int i = 1; i <= n; i ++){
        q[tt++] = i;
        st[i] = true;
    }

    while(hh != tt)
    {
        int temp = q[hh ++];
        if(hh == N) hh = 0;
        st[temp] = false;

        for(int i = h[temp]; i != -1; i = ne[i])
        {
            int j = e[i];
            double a = (double) f[temp] - (double) mid * t[i];
            if(dist[j] < a + dist[temp])
            {
                dist[j] = a + dist[temp];
                cnt[j] = cnt[temp] + 1;
                
                if(cnt[j] >= n){
                    return true;
                }
                if(!st[j])
                {
                    q[tt++] = j;
                    if(tt == N) tt = 0;
                    st[j] = true;
                }

               
            }
        }
    }

    return false;

}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    memset(h, -1, sizeof h);

    scanf("%d%d", &n, &m);

    for(int i = 1; i <= n; i ++){
        scanf("%d", &f[i]);
    }

    for(int i = 0; i < m; i ++){
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        add(a, b, c);
    }


    double l = 0, r = 1000;
    while(r - l > eps){
        double mid = (double)(l + r) / 2.0;
        if(check(mid)) l = mid;
        else r = mid;
    }

    printf("%.2f", l);
}